package cn.chenyumeng.blog.configuration;

import cn.chenyumeng.blog.interceptor.ArticleClickInterceptor;
import cn.chenyumeng.blog.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @program: blog->LoginConfiguration
 * @description:
 * @author: cg
 * @create: 2020-07-27 11:38
 **/
@Configuration
public class WebConfiguration implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Autowired
    private ArticleClickInterceptor articleClickInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/admin/**")
                .excludePathPatterns("/admin/user/login");
        registry.addInterceptor(articleClickInterceptor)
                .addPathPatterns("/blog/**");
    }
}
